import axios from 'axios';

let base = '/api/admin';
// 登录接口
export const requestLogin = params => { return axios.post(`${base}/login`, params).then(res => res.data); };

export const requestMenus = params => { return axios.get(`${base}/menus`, params).then(res => res.data); };
// 用户列表
export const getUserListPage = params => { return axios.get(`${base}/user/list`, { params: params }); };
// 添加/编辑用户
export const saveUser = params => { return axios.post(`${base}/user/save`, params).then(res=>res.data); };
// 删除用户
export const removeUser = params => { return axios.delete(`${base}/user/delete`, { params: params }); };

// 菜单列表
export const getMenuList = params => { return axios.get(`${base}/menu/list`, { params: params }); };
// 树状结构
export const getMenuTree = params => { return axios.get(`${base}/menu/tree`, { params: params }); };
// 添加菜单
export const saveMenu = params => { return axios.post(`${base}/menu/save`, params).then(res=>res.data); };
// 删除菜单
export const deleteMenuApi = params => { return axios.delete(`${base}/menu/delete`, { params: params }); };

// 菜单列表
export const getRoleList = params => { return axios.get(`${base}/role/list`, { params: params }); };
// 添加菜单
export const saveRole = params => { return axios.post(`${base}/role/save`, params).then(res=>res.data); };
// 删除菜单
export const deleteRoleApi = params => { return axios.delete(`${base}/role/delete`, { params: params }); };
// 提交权限
export const saveRoleMenus = params => { return axios.post(`${base}/role/saveRoleMenus`, params).then(res=>res.data); };

// 查询管理员列表
export const getAdminListPage = params => { return axios.get(`${base}/user/admins`, { params: params }); };
// 管理员页面获取角色
export const getEnableRole = params => { return axios.get(`${base}/user/roles`, { params: params }); };
// 保存管理员
export const saveAdmin = params => { return axios.post(`${base}/user/admin/save`, params).then(res=>res.data); };

// 取公众号
export const getAccounts = params =>{return axios.get(`${base}/account/list`,params).then(res=>res.data) }
export const getAccountMenus = params =>{return axios.get(`${base}/account/menus/list`,params).then(res=>res.data) }
export const postWxMenus = params =>{return axios.post(`${base}/account/menus/reset`,params).then(res=>res.data) }
export const clearAccountMenus = params =>{return axios.delete(`${base}/account/menus/delete`,params).then(res=>res.data) }
